Begin;
-- ## [created : 01/12/2007, 02:32:55 PM]
-- ## Description:to create master tables on _100351 schema for export Documentaion
-- ##Created by G.M.Sundar
-- PostgreSQL database dump
--
SET client_encoding = 'UTF8';
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- Name: _100351; Type: SCHEMA; Schema: -; Owner: leatherlink
--
CREATE SCHEMA _100351;

ALTER SCHEMA _100351 OWNER TO leatherlink;

SET search_path = _100351, pg_catalog;
--
-- Name: dm_description; Type: DOMAIN; Schema: _100351; Owner: leatherlink
--

CREATE DOMAIN dm_description AS character varying[];


ALTER DOMAIN _100351.dm_description OWNER TO leatherlink;

--
-- Name: dm_entered_time; Type: DOMAIN; Schema: _100351; Owner: leatherlink
--

CREATE DOMAIN dm_entered_time AS timestamp without time zone DEFAULT now();


ALTER DOMAIN _100351.dm_entered_time OWNER TO leatherlink;
--
-- Name: dm_data_status; Type: DOMAIN; Schema: _100351; Owner: leatherlink
--

CREATE DOMAIN dm_data_status AS character(3)
	CONSTRAINT dm_data_status CHECK ((((((VALUE = 'act'::bpchar) OR (VALUE = 'can'::bpchar)) OR (VALUE = 'com'::bpchar)) OR (VALUE = 'del'::bpchar)) OR (VALUE = 'sus'::bpchar)));


ALTER DOMAIN _100351.dm_data_status OWNER TO leatherlink;

--
-- Name: dm_rate; Type: DOMAIN; Schema: _100351; Owner: leatherlink
--

CREATE DOMAIN dm_rate AS numeric
	CONSTRAINT dm_rate_chk CHECK (((VALUE <= (100)::numeric) AND (VALUE >= (-100)::numeric)));


ALTER DOMAIN _100351.dm_rate OWNER TO leatherlink;



CREATE SEQUENCE sys_seq_mll_language_id
    INCREMENT BY 1
    NO MAXVALUE
    NO MINVALUE
    CACHE 1;


--
-- Name: sys_master_user; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_master_user (
    user_id integer DEFAULT nextval(('sys_seq_mu_user_id'::text)::regclass) NOT NULL,
    login_name character varying,
    access_code character varying
);



ALTER TABLE _100351.sys_master_user OWNER TO leatherlink;
--
-- Name: sys_master_user_type; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_master_user_type (
    user_type_id character(3) NOT NULL,
    user_scope character(1),
    user_type_desc character varying,
    CONSTRAINT sys_mus_user_scope_chk CHECK ((((user_scope = 'e'::bpchar) OR (user_scope = 'i'::bpchar)) OR (user_scope = 's'::bpchar)))
);


ALTER TABLE _100351.sys_master_user_type OWNER TO leatherlink;
--
-- Name: sys_master_privilege; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_master_privilege (
    privilege_id integer DEFAULT nextval(('sys_seq_mpv_privilege_id'::text)::regclass) NOT NULL,
    module_id character(3),
    data_category_desc dm_description,
    CONSTRAINT sys_mpr_data_category_desc_chk CHECK ((((((data_category_desc[1])::text = 'commercial'::text) OR ((data_category_desc[1])::text = 'financial'::text)) OR ((data_category_desc[1])::text = 'product'::text)) OR ((data_category_desc[1])::text = 'internal'::text)))
);


ALTER TABLE _100351.sys_master_privilege OWNER TO leatherlink;
--
-- Name: sys_master_preferences; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_master_preferences (
    preference_id integer DEFAULT nextval(('sys_seq_mpr_preference_id'::text)::regclass) NOT NULL,
    preference_desc dm_description,
    default_values character varying
);


ALTER TABLE _100351.sys_master_preferences OWNER TO leatherlink;
--
-- Name: sys_company_preferences; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_company_preferences (
    preference_id integer,
    preferred_values character varying
);
--
-- Name: sys_user_privilege; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_user_privilege (
    user_id integer NOT NULL,
    privilege_id integer NOT NULL,
    permission character(3),
    CONSTRAINT sys_upr_permission_chk CHECK ((permission ~ '^[r|-][e|-][m|-]$'::text))
);
--
-- Name: sys_user_info; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_user_info (
    user_id integer NOT NULL,
    user_type_id character(3) NOT NULL,
    relationship_id integer,
    first_name character varying,
    last_name character varying,
    initials character(4)
);


ALTER TABLE _100351.sys_user_info OWNER TO leatherlink;
--
-- Name: sys_master_company; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_master_company (
    company_id integer DEFAULT nextval(('sys_seq_mco_company_id'::text)::regclass) NOT NULL,
    company_name dm_description
);


ALTER TABLE _100351.sys_master_company OWNER TO leatherlink;
--
-- Name: sys_company_product_details; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_company_product_details (
    product_details_id integer DEFAULT nextval(('sys_seq_cpd_product_details_id'::text)::regclass) NOT NULL,
    relationship_id integer,
    product_category_id integer,
    activity_id character(3)
);

--
-- Name: sys_master_relationship; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE sys_master_relationship (
    relationship_id integer DEFAULT nextval(('sys_seq_mre_relationship_id'::text)::regclass) NOT NULL,
    partner_id integer NOT NULL,
    partner_code character varying,
    product_details_id integer,
    financial_details_id integer,
    commercial_details_id integer,
    contact_details_id integer,
    payment_term_id character(3),
    shipment_term_id character(3),
    credit_days integer,
    agent_id integer,
    agent_commission dm_rate,
    zone_id integer,
    entered_by integer,
    entered_time dm_entered_time,
    record_status dm_data_status,
    CONSTRAINT sys_mre_credit_days_chk CHECK ((credit_days >= 0))
);


ALTER TABLE _100351.sys_master_relationship OWNER TO leatherlink;
--
-- Name: gen_user_preferences; Type: TABLE; Schema: _100351; Owner: leatherlink; Tablespace:
--

CREATE TABLE gen_user_preferences (
    user_id integer NOT NULL,
    preference_id integer NOT NULL,
    preferred_values character varying
);


ALTER TABLE _100351.gen_user_preferences OWNER TO leatherlink;




CREATE TABLE sys_master_language (
    language_id integer DEFAULT nextval('sys_seq_mll_language_id'::text) NOT
NULL,
    language_code character(4),
    language_desc character varying
);


--
-- Data for Name: gen_user_preferences; Type: TABLE DATA; Schema: _100351; Owner: leatherlink
--
COMMIT;